package com.huqing.icu.service.savestrategy;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Optional;

/**
 * 房源新增的匹配策略
 *
 * @author huqing
 * @date 2024-09-28 22:01
 */
@Component
public class HouseSaveServiceHandler {
    @Autowired
    private List<AbstractHouseSaveService> list;


    /**
     * 获取房东身份实例
     *
     * @param <T>
     * @return
     */
    public <T> T getHouseOwnerInstance(Integer houseOwner) {
        Optional<AbstractHouseSaveService> first = list.stream().filter(o -> o.judgeHouseOwner(houseOwner)).findFirst();
        if (first.isPresent()) {
            return (T) first.get();
        }
        return null;
    }

}
